﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'Body')
	BEGIN
		DROP  Table Body
	END
GO

CREATE TABLE Body
(
   BodyId int identity(1,1) not null,
   AccountId int not null,
   EntryDate datetime not null,
   Weight float,
   BodyFat float,
   BMI float,
   Waist float,
   Chest float,
   Arms float,
   Thighs float,
   Height float
   
   constraint pkBody primary key (BodyId),
   constraint fkBodyToAccount foreign key (AccountId) references Account (AccountId),
   constraint ck_WeightRange check (Weight > 0),
   constraint ck_BodyFat check (BodyFat > 0 and BodyFat <= 100),
   constraint ck_BMI check (BMI > 0),
   constraint ck_Waist check (Waist > 0),
   constraint ck_Chest check (Chest > 0),
   constraint ck_Arms check (Arms > 0),
   constraint ck_Thighs check (Thighs > 0),
   constraint ck_Height check (Height > 0)
)
GO 